package com.google.rpc;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class RemoteInvocationHandler implements InvocationHandler {

    String host;
    int port;

    public RemoteInvocationHandler(String host , int port) {
        this.host = host;
        this.port = port;
    }
    @Override
    public Object invoke(Object proxy , Method method , Object[] args) throws Throwable {
        RPCRequest request=new RPCRequest();
        request.setClassName(method.getDeclaringClass().getName());
        request.setMethodName(method.getName());
        request.setParams(args);
        RPCNetTransport rpcNetTransport=new RPCNetTransport(host,port);
        return rpcNetTransport.send(request);
    }
}
